package servlet;

import java.io.IOException;
import java.util.Arrays;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/req")
public class RequestServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//1.得到参数
		String name = req.getParameter("name");
		System.out.println("name:" + name.length());
		String[] hobby = req.getParameterValues("hobby");
		System.out.println("hobby:" + Arrays.toString(hobby));
		
		// 2.得到请求路径
		String uri = req.getRequestURI();
		System.out.println("uri:" + uri);
		StringBuffer url = req.getRequestURL();
		System.out.println("url:" + url);
		
		//请求路径：.../req?name=zhangsan&hobby=ps&hobby=tw
	}

	
}
